package com.cool.reggie.utils;

import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Author ifredomvip@gmail.com
 * @Date 2022/7/4 15:02
 * @Version 1.0.0
 * @Description
 **/
@Data
public class PageUtils implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 当前页数
     */
    private long currPage;
    /**
     * 每页记录数
     */
    private long pageSize;
    /**
     * 总条数
     */
    private long totalCount;
    /**
     * 总页数
     */
    private long totalPage;
    /**
     * 列表数据
     */
    private List<?> list;

    /**
     * 没有参数
     */
    public PageUtils() {
        this.currPage = 1L;
        this.pageSize = 10L;
        this.totalCount = 0L;
        this.totalPage = 0L;
        this.list = Collections.emptyList();
    }
    /**
     * 两个参数
     *
     * @param currPage   当前页数
     * @param pageSize   每页记录数
     */
    public PageUtils(long currPage,long pageSize) {
        this(currPage,pageSize,0);
    }
    /**
     * 三个参数
     *
     * @param currPage   当前页数
     * @param pageSize   每页记录数
     * @param totalCount 总记录数
     */
    public PageUtils(long currPage,long pageSize,long totalCount) {
        this.currPage = currPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
    }

    /**
     * 分页
     * @param page   page实例
     */
    public PageUtils(Page<?> page) {
        this.currPage = page.getCurrent();
        this.pageSize = page.getSize();
        this.totalCount = page.getTotal();
        this.list = page.getRecords();
    }

}
